import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _isArray from "lodash/isArray";
import _cloneDeep from "lodash/cloneDeep";
var _excluded = ["children"],
    _excluded2 = ["_status"],
    _excluded3 = ["_status"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _class, _class2;

/**
 * ReceiveConfig - 消息接收配置
 * @date: 2018-11-21

 */
import React, { Component } from 'react';
import { Form, Input, Popconfirm, Select, Tag, Button } from 'antd';
import { connect } from 'dva';
import uuidv4 from 'uuid/v4';
import { Bind } from 'lodash-decorators';
import Lov from 'components/Lov';
import { Content, Header } from 'components/Page';
import TLEditor from 'components/TLEditor';
import EditTable from 'components/EditTable';
import { Button as ButtonPermission } from 'components/Permission';
import notification from 'utils/notification';
import { VERSION_IS_OP } from 'utils/config';
import intl from 'utils/intl';
import formatterCollections from 'utils/intl/formatterCollections';
import { getEditTableData, tableScrollWidth, isTenantRoleLevel, getCurrentOrganizationId } from 'utils/utils';
import { CODE_UPPER } from 'utils/regExp';
import { operatorRender } from 'utils/renderer';
import styles from "./index.less?modules";
var selRefs = {};
var currentTenantId = getCurrentOrganizationId();
var tenantRoleLevel = isTenantRoleLevel();

function onSelRef(key, ref) {
  if (ref) {
    selRefs[key] = ref;
  } else if (selRefs[key]) {
    delete selRefs[key];
  }
}

var ReceiveConfig = (_dec = connect(function (_ref) {
  var receiveConfig = _ref.receiveConfig,
      loading = _ref.loading,
      user = _ref.user;
  return {
    user: user,
    receiveConfig: receiveConfig,
    searchLoading: loading.effects['receiveConfig/fetchReceiveConfig'],
    saveLoading: loading.effects['receiveConfig/saveConfig']
  };
}), _dec2 = formatterCollections({
  code: ['cmsg.receiveConfig', 'cmsg.common']
}), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(500), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_Component) {
  _inherits(ReceiveConfig, _Component);

  var _super = _createSuper(ReceiveConfig);

  /**
   * state初始化
   * @param {object} props 组件Props
   */
  function ReceiveConfig(props) {
    var _this;

    _classCallCheck(this, ReceiveConfig);

    _this = _super.call(this, props);
    _this.form = void 0;
    _this.state = {
      expandedRowKeys: [],
      // 当前展开的树
      checkedTenantId: currentTenantId,
      // 选中的租户id
      createFlag: false
    };
    return _this;
  }
  /**
   * componentDidMount 生命周期函数
   * render执行后获取页面数据
   */


  _createClass(ReceiveConfig, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var dispatch = this.props.dispatch;
      this.handleSearch();
      dispatch({
        type: 'receiveConfig/fetchMessageType'
      });
    }
    /**
     * 根据节点路径，在树形结构树中的对应节点添加或替换children属性
     * @param {Array} collections 树形结构树
     * @param {Array} cursorPath 节点路径
     * @param {Array} data  追加或替换的children数据
     * @returns {Array} 新的树形结构
     */

  }, {
    key: "findAndSetNodeProps",
    value: function findAndSetNodeProps(collections) {
      var _this2 = this;

      var cursorPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
      var data = arguments.length > 2 ? arguments[2] : undefined;
      var newCursorList = cursorPath;
      var cursor = newCursorList[0];
      var tree = collections.map(function (n) {
        var m = n;

        if (m.receiveCode === cursor) {
          if (newCursorList[1]) {
            if (!m.children) {
              m.children = [];
            }

            newCursorList = newCursorList.filter(function (o) {
              return newCursorList.indexOf(o) !== 0;
            });
            m.children = _this2.findAndSetNodeProps(m.children, newCursorList, data);
          } else {
            m.children = _toConsumableArray(data);
          }

          if (m.children.length === 0) {
            var children = m.children,
                others = _objectWithoutProperties(m, _excluded);

            return _objectSpread({}, others);
          } else {
            return m;
          }
        }

        return m;
      });
      return tree;
    }
    /**
     * 根据节点路径，在树形结构树中的对应节点
     * @param {Array} collection 树形结构树
     * @param {Array} cursorList 节点路径
     * @param {String} keyName 主键名称
     * @returns {Object} 节点信息
     */

  }, {
    key: "findNode",
    value: function findNode(collection) {
      var cursorList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
      var keyName = arguments.length > 2 ? arguments[2] : undefined;
      var newCursorList = cursorList;
      var cursor = newCursorList[0];

      for (var i = 0; i < collection.length; i++) {
        if (collection[i][keyName] === cursor) {
          if (newCursorList[1]) {
            newCursorList = newCursorList.slice(1);
            return this.findNode(collection[i].children, newCursorList, keyName);
          }

          return collection[i];
        }
      }
    }
  }, {
    key: "handleSearch",
    value: function handleSearch() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'receiveConfig/fetchReceiveConfig',
        payload: params
      });
      this.setState({
        createFlag: false
      });
    } // 新增下级配置

  }, {
    key: "handleAddLine",
    value: function handleAddLine() {
      var record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props = this.props,
          _this$props$receiveCo = _this$props.receiveConfig,
          configList = _this$props$receiveCo.configList,
          _this$props$receiveCo2 = _this$props$receiveCo.pathMap,
          pathMap = _this$props$receiveCo2 === void 0 ? {} : _this$props$receiveCo2,
          dispatch = _this$props.dispatch;
      var expandedRowKeys = this.state.expandedRowKeys;

      if (record.receiveId) {
        var newConfig = {
          receiveId: uuidv4(),
          receiveCode: '',
          receiveName: '',
          // levelNumber: record.levelNumber,
          defaultReceiveType: [],
          parentReceiveCode: record.receiveCode,
          _status: 'create' // 新增节点的标识

        };
        var newChildren = [newConfig].concat(_toConsumableArray(record.children || []));
        var newConfigList = this.findAndSetNodeProps(configList, pathMap[record.receiveCode], newChildren);
        this.setState({
          expandedRowKeys: [].concat(_toConsumableArray(expandedRowKeys), [record.receiveId])
        }, function () {
          dispatch({
            type: 'receiveConfig/updateState',
            payload: {
              configList: newConfigList
            }
          });
        });
      } else {
        var _newConfig = {
          receiveId: uuidv4(),
          receiveCode: '',
          receiveName: '',
          defaultReceiveType: [],
          parentReceiveCode: record.receiveCode,
          _status: 'create' // 新增节点的标识

        };

        var _newConfigList = [_newConfig].concat(_toConsumableArray(configList));

        dispatch({
          type: 'receiveConfig/updateState',
          payload: {
            configList: _newConfigList
          }
        });
      }

      this.setState({
        createFlag: true
      });
    } // 保存

  }, {
    key: "handleSave",
    value: function handleSave() {
      var _this3 = this;

      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          _this$props2$receiveC = _this$props2.receiveConfig;
      _this$props2$receiveC = _this$props2$receiveC === void 0 ? {} : _this$props2$receiveC;
      var _this$props2$receiveC2 = _this$props2$receiveC.configList,
          configList = _this$props2$receiveC2 === void 0 ? [] : _this$props2$receiveC2;
      var checkedTenantId = this.state.checkedTenantId;
      var params = getEditTableData(configList, ['children', 'receiveId']);

      if (Array.isArray(params) && params.length !== 0) {
        var payloadParams = params.map(function (item) {
          return _objectSpread(_objectSpread({}, item), {}, {
            defaultReceiveType: _isArray(item.defaultReceiveType) ? item.defaultReceiveType.join(',') : item.defaultReceiveType
          });
        });
        var allParams = {
          payloadParams: payloadParams,
          checkedTenantId: checkedTenantId
        };
        dispatch({
          type: 'receiveConfig/saveConfig',
          payload: allParams
        }).then(function (res) {
          if (res) {
            notification.success();

            _this3.handleSearch();
          }
        });
      }
    } // 取消

  }, {
    key: "handleCancel",
    value: function handleCancel(record) {
      var receiveId = record.receiveId;
      var _this$props3 = this.props,
          _this$props3$receiveC = _this$props3.receiveConfig;
      _this$props3$receiveC = _this$props3$receiveC === void 0 ? {} : _this$props3$receiveC;
      var _this$props3$receiveC2 = _this$props3$receiveC.configList,
          configList = _this$props3$receiveC2 === void 0 ? [] : _this$props3$receiveC2,
          pathMap = _this$props3$receiveC.pathMap,
          dispatch = _this$props3.dispatch;
      var newConfigList = configList;

      if (record.parentReceiveCode) {
        var parentNode = this.findNode(configList, pathMap[record.parentReceiveCode], 'receiveCode');
        var newChildren = parentNode.children.filter(function (item) {
          return item.receiveId !== receiveId;
        });
        newConfigList = this.findAndSetNodeProps(configList, pathMap[record.parentReceiveCode], newChildren);
      } else {
        newConfigList = configList.filter(function (item) {
          return item.receiveId !== receiveId;
        });
      }

      dispatch({
        type: 'receiveConfig/updateState',
        payload: {
          configList: newConfigList
        }
      });
    } // 编辑树结构信息

  }, {
    key: "handleEdit",
    value: function handleEdit(record, flag) {
      var receiveId = record.receiveId;
      var _this$props4 = this.props,
          _this$props4$receiveC = _this$props4.receiveConfig;
      _this$props4$receiveC = _this$props4$receiveC === void 0 ? {} : _this$props4$receiveC;
      var _this$props4$receiveC2 = _this$props4$receiveC.configList,
          configList = _this$props4$receiveC2 === void 0 ? [] : _this$props4$receiveC2,
          pathMap = _this$props4$receiveC.pathMap,
          dispatch = _this$props4.dispatch;
      var newConfigList = configList;

      if (record.parentReceiveCode) {
        var parentNode = this.findNode(configList, pathMap[record.parentReceiveCode], 'receiveCode');

        var newChildren = _cloneDeep(parentNode.children);

        var index = newChildren.findIndex(function (item) {
          return item.receiveId === receiveId;
        });

        if (flag) {
          newChildren.splice(index, 1, _objectSpread(_objectSpread({}, record), {}, {
            _status: 'update'
          }));
        } else {
          var _status = record._status,
              other = _objectWithoutProperties(record, _excluded2);

          newChildren.splice(index, 1, other);
        }

        newConfigList = this.findAndSetNodeProps(configList, pathMap[record.parentReceiveCode], newChildren);
      } else {
        var _index = newConfigList.findIndex(function (item) {
          return item.receiveId === receiveId;
        });

        if (flag) {
          newConfigList.splice(_index, 1, _objectSpread(_objectSpread({}, configList[_index]), {}, {
            _status: 'update'
          }));
        } else {
          var _configList$_index = configList[_index],
              _status2 = _configList$_index._status,
              _other = _objectWithoutProperties(_configList$_index, _excluded3);

          newConfigList.splice(_index, 1, _other);
        }
      }

      dispatch({
        type: 'receiveConfig/updateState',
        payload: {
          configList: newConfigList
        }
      });
    } // 取消新建下级

  }, {
    key: "handleCleanLine",
    value: function handleCleanLine() {
      var record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props5 = this.props,
          dispatch = _this$props5.dispatch,
          _this$props5$receiveC = _this$props5.receiveConfig,
          _this$props5$receiveC2 = _this$props5$receiveC.renderTree,
          renderTree = _this$props5$receiveC2 === void 0 ? [] : _this$props5$receiveC2,
          _this$props5$receiveC3 = _this$props5$receiveC.addData,
          addData = _this$props5$receiveC3 === void 0 ? {} : _this$props5$receiveC3,
          _this$props5$receiveC4 = _this$props5$receiveC.pathMap,
          pathMap = _this$props5$receiveC4 === void 0 ? {} : _this$props5$receiveC4;
      delete addData[record.receiveId];
      var newRenderTree = [];

      if (record.parentReceiveCode) {
        // 找到父节点的children, 更新children数组
        var parent = this.findNode(renderTree, pathMap[record.parentReceiveCode], 'receiveCode');
        var newChildren = parent.children.filter(function (item) {
          return item.receiveId !== record.receiveId;
        });
        newRenderTree = this.findAndSetNodeProps(renderTree, pathMap[record.parentReceiveCode], newChildren);
      } else {
        newRenderTree = renderTree.filter(function (item) {
          return item.receiveId !== record.receiveId;
        });
      }

      dispatch({
        type: 'receiveConfig/updateState',
        payload: {
          renderTree: newRenderTree,
          addData: _objectSpread({}, addData)
        }
      });
    } // 删除

  }, {
    key: "handleDelete",
    value: function handleDelete(record) {
      var _this4 = this;

      var dispatch = this.props.dispatch;
      var checkedTenantId = this.state.checkedTenantId;
      dispatch({
        type: 'receiveConfig/deleteConfig',
        payload: _objectSpread(_objectSpread({}, record), {}, {
          checkedTenantId: checkedTenantId
        })
      }).then(function (res) {
        if (res) {
          notification.success();

          _this4.handleSearch();
        }
      });
    }
    /**
     * 树形结构点击展开收起时的回调
     */

  }, {
    key: "onExpand",
    value: function onExpand(expanded, record) {
      var receiveId = record.receiveId;
      var expandedRowKeys = this.state.expandedRowKeys;

      if (expanded) {
        this.setState({
          expandedRowKeys: [].concat(_toConsumableArray(expandedRowKeys), [receiveId])
        });
      } else {
        var newExpandRowKeys = expandedRowKeys.filter(function (item) {
          return item !== receiveId;
        });
        this.setState({
          expandedRowKeys: newExpandRowKeys
        });
      }
    }
  }, {
    key: "typeMeaningRender",
    value: function typeMeaningRender(tagValue, tagMeaning) {
      var mean = '';

      switch (tagValue) {
        case 'WEB':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "green",
            key: "1"
          }, tagMeaning);
          break;

        case 'EMAIL':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "orange",
            key: "2"
          }, tagMeaning);
          break;

        case 'SMS':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "blue",
            key: "3"
          }, tagMeaning);
          break;

        case 'WC_E':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "red",
            key: "4"
          }, tagMeaning);
          break;

        case 'WC_O':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "#9866ff",
            key: "5"
          }, tagMeaning);
          break;

        case 'DT':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "pink",
            key: "6"
          }, tagMeaning);
          break;

        case 'CALL':
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "#00ccff",
            key: "7"
          }, tagMeaning);
          break;

        default:
          mean = /*#__PURE__*/React.createElement(Tag, {
            color: "#dcdcdc",
            key: "8"
          }, tagMeaning);
          break;
      }

      return mean;
    }
    /**
     * 租户lov改变时触发
     * @param {object} record
     */

  }, {
    key: "handleChangeOrg",
    value: function handleChangeOrg(record) {
      this.handleSearch({
        tenantId: record.tenantId
      });
      this.setState({
        checkedTenantId: record.tenantId
      });
    }
    /**
     * 刷新
     */

  }, {
    key: "handleRefresh",
    value: function handleRefresh() {
      var checkedTenantId = this.state.checkedTenantId;
      var obj = !tenantRoleLevel ? {
        tenantId: checkedTenantId
      } : {};
      this.handleSearch(obj);
    }
    /**
     * render
     * @returns React.element
     */

  }, {
    key: "render",
    value: function render() {
      var _this5 = this;

      var _this$props6 = this.props,
          receiveConfig = _this$props6.receiveConfig,
          searchLoading = _this$props6.searchLoading,
          saveLoading = _this$props6.saveLoading,
          path = _this$props6.match.path,
          tenantName = _this$props6.user.currentUser.tenantName;
      var _receiveConfig$config = receiveConfig.configList,
          configList = _receiveConfig$config === void 0 ? [] : _receiveConfig$config,
          messageTypeList = receiveConfig.messageTypeList;
      var _this$state$expandedR = this.state.expandedRowKeys,
          expandedRowKeys = _this$state$expandedR === void 0 ? [] : _this$state$expandedR;
      var columns = [{
        title: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveCode').d('接收配置编码'),
        dataIndex: 'receiveCode',
        render: function render(val, record) {
          return record._status === 'create' || record._status === 'update' ? /*#__PURE__*/React.createElement(Form.Item, {
            style: {
              width: '250px'
            }
          }, record.$form.getFieldDecorator('receiveCode', {
            initialValue: val,
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveCode').d('接收配置编码')
              })
            }, {
              pattern: CODE_UPPER,
              message: intl.get('cpaas.common.validation.codeUpper').d('全大写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
            }]
          })( /*#__PURE__*/React.createElement(Input, {
            trim: true,
            typeCase: "upper",
            inputChinese: false,
            disabled: record._status === 'update'
          }))) : val;
        }
      }, {
        title: intl.get('cmsg.common.view.source').d('来源'),
        dataIndex: 'tenantId',
        width: 120,
        render: function render(_, record) {
          var tenantId = record.tenantId; // eslint-disable-next-line no-nested-ternary

          if (tenantId === undefined) {
            return /*#__PURE__*/React.createElement(Tag, {
              color: "green"
            }, intl.get('cpaas.common.custom').d('自定义'));
          } else {
            // eslint-disable-next-line no-nested-ternary
            return !record.editableFlag ? /*#__PURE__*/React.createElement(Tag, {
              color: "blue"
            }, intl.get('cmsg.receiveConfig.model.receiveConfig.sendConfig').d('发送配置')) : currentTenantId.toString() === tenantId.toString() ? /*#__PURE__*/React.createElement(Tag, {
              color: "green"
            }, intl.get('cpaas.common.custom').d('自定义')) : /*#__PURE__*/React.createElement(Tag, {
              color: "orange"
            }, intl.get('cpaas.common.predefined').d('预定义'));
          }
        }
      }, {
        title: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveName').d('接收配置名称'),
        dataIndex: 'receiveName',
        width: 150,
        render: function render(val, record) {
          return record._status === 'create' || record._status === 'update' ? /*#__PURE__*/React.createElement(Form.Item, null, record.$form.getFieldDecorator('receiveName', {
            initialValue: val,
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveName').d('接收配置名称')
              })
            }]
          })( /*#__PURE__*/React.createElement(TLEditor, {
            label: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveName').d('接收配置名称'),
            field: "receiveName",
            token: record._token
          }))) : val;
        }
      }, {
        title: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveType').d('默认接收方式'),
        dataIndex: 'defaultReceiveType',
        width: 420,
        render: function render(val, record) {
          if (record._status === 'create' || record._status === 'update') {
            return /*#__PURE__*/React.createElement(Form.Item, null, record.$form.getFieldDecorator('defaultReceiveType', {
              initialValue: _isArray(val) ? val : val.split(','),
              rules: [{
                required: true,
                message: intl.get('cpaas.common.validation.notNull', {
                  name: intl.get('cmsg.receiveConfig.model.receiveConfig.receiveType').d('默认接收方式')
                })
              }]
            })( /*#__PURE__*/React.createElement(Select, {
              style: {
                width: 250
              },
              mode: "multiple",
              onFocus: function onFocus() {
                if (selRefs["selRef".concat(record.receiveId)]) {
                  selRefs["selRef".concat(record.receiveId)].rcSelect.setOpenState(true);
                }
              },
              ref: function ref(r) {
                onSelRef("selRef".concat(record.receiveId), r);
              }
            }, messageTypeList.map(function (item) {
              return /*#__PURE__*/React.createElement(Select.Option, {
                key: item.value,
                value: item.value
              }, item.meaning);
            }))));
          } else {
            var tagValueList = record.defaultReceiveType.split(',') || [];
            var tagMeaningList = record.defaultReceiveTypeMeaning.split(',') || [];
            var tagIndexMap = tagValueList.reduce(function (p, v, valueIndex) {
              return _objectSpread(_objectSpread({}, p), {}, _defineProperty({}, v, {
                oriValueIndex: valueIndex
              }));
            }, {});
            return tagValueList.sort().map(function (item) {
              return _this5.typeMeaningRender(item, tagMeaningList[tagIndexMap[item].oriValueIndex]);
            });
          }
        }
      }, {
        title: intl.get('cpaas.common.button.action').d('操作'),
        dataIndex: 'operator',
        width: 200,
        render: function render(val, record) {
          var operators = [];

          if (record.levelNumber !== 0) {
            if (record._status === 'create') {
              operators.push({
                key: 'cancel',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.cancel"),
                    type: 'button',
                    meaning: '消息接收配置-取消'
                  }],
                  style: {
                    cursor: 'pointer'
                  },
                  onClick: function onClick() {
                    return _this5.handleCancel(record);
                  }
                }, intl.get('cpaas.common.button.cancel').d('取消')),
                len: 2,
                title: intl.get('cpaas.common.button.cancel').d('取消')
              });
            } else if (record._status === 'update') {
              operators.push({
                key: 'cancelEdit',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.cancelEdit"),
                    type: 'button',
                    meaning: '消息接收配置-取消编辑'
                  }],
                  onClick: function onClick() {
                    return _this5.handleEdit(record, false);
                  },
                  style: {
                    cursor: 'pointer'
                  }
                }, intl.get('cpaas.common.button.cancel').d('取消')),
                len: 2,
                title: intl.get('cpaas.common.button.cancel').d('取消')
              }, record.editableFlag && {
                key: 'createChildren',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.createChildren"),
                    type: 'button',
                    meaning: '消息接收配置-新建下级配置'
                  }],
                  onClick: function onClick() {
                    return _this5.handleAddLine(record);
                  }
                }, intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')),
                len: 6,
                title: intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')
              }, record.editableFlag && {
                key: 'delete',
                ele: /*#__PURE__*/React.createElement(Popconfirm, {
                  placement: "topRight",
                  title: intl.get('cpaas.common.message.confirm.delete').d('是否删除此条记录？'),
                  onConfirm: function onConfirm() {
                    return _this5.handleDelete(record);
                  }
                }, /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.delete"),
                    type: 'button',
                    meaning: '消息接收配置-删除'
                  }]
                }, intl.get('cpaas.common.button.delete').d('删除'))),
                len: 2,
                title: intl.get('cpaas.common.button.delete').d('删除')
              });
            } else if (tenantRoleLevel && !VERSION_IS_OP && currentTenantId.toString() !== record.tenantId.toString()) {
              operators.push(record.editableFlag && {
                key: 'edit1',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.edit"),
                    type: 'button',
                    meaning: '消息接收配置-编辑'
                  }],
                  onClick: function onClick() {
                    return _this5.handleEdit(record, true);
                  },
                  style: {
                    cursor: 'pointer'
                  }
                }, intl.get('cpaas.common.button.edit').d('编辑')),
                len: 2,
                title: intl.get('cpaas.common.button.edit').d('编辑')
              }, record.editableFlag && {
                key: 'createChildren3',
                ele: /*#__PURE__*/React.createElement("a", {
                  onClick: function onClick() {
                    return _this5.handleAddLine(record);
                  }
                }, intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')),
                len: 6,
                title: intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')
              });
            } else {
              operators.push(record.editableFlag && {
                key: 'edit',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.edit"),
                    type: 'button',
                    meaning: '消息接收配置-编辑'
                  }],
                  onClick: function onClick() {
                    return _this5.handleEdit(record, true);
                  },
                  style: {
                    cursor: 'pointer'
                  }
                }, intl.get('cpaas.common.button.edit').d('编辑')),
                len: 2,
                title: intl.get('cpaas.common.button.edit').d('编辑')
              }, record.editableFlag && {
                key: 'createChildren2',
                ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.createChildren"),
                    type: 'button',
                    meaning: '消息接收配置'
                  }],
                  onClick: function onClick() {
                    return _this5.handleAddLine(record);
                  }
                }, intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')),
                len: 6,
                title: intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')
              }, record.editableFlag && {
                key: 'delete1',
                ele: /*#__PURE__*/React.createElement(Popconfirm, {
                  placement: "topRight",
                  title: intl.get('cpaas.common.message.confirm.delete').d('是否删除此条记录？'),
                  onConfirm: function onConfirm() {
                    return _this5.handleDelete(record);
                  }
                }, /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.delete"),
                    type: 'button',
                    meaning: '消息接收配置-删除'
                  }]
                }, intl.get('cpaas.common.button.delete').d('删除'))),
                len: 2,
                title: intl.get('cpaas.common.button.delete').d('删除')
              });
            }
          } else {
            operators.push(record.editableFlag && {
              key: 'createChildren2',
              ele: /*#__PURE__*/React.createElement("a", {
                onClick: function onClick() {
                  return _this5.handleAddLine(record);
                }
              }, intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')),
              len: 6,
              title: intl.get('cmsg.receiveConfig.option.createChildren').d('新建下级配置')
            });
          }

          return operatorRender(operators);
        }
      }].filter(Boolean);
      var editTableProps = {
        expandedRowKeys: expandedRowKeys,
        columns: columns,
        scroll: {
          x: tableScrollWidth(columns)
        },
        loading: searchLoading,
        rowKey: 'receiveId',
        pagination: false,
        bordered: true,
        dataSource: configList,
        onExpand: this.onExpand,
        indentSize: 24,
        className: styles['cmsg-hr-show']
      };
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
        title: intl.get('cmsg.receiveConfig.view.message.title').d('消息接收配置')
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.save"),
          type: 'button',
          meaning: '消息接收配置-保存'
        }],
        icon: "save",
        type: "primary",
        onClick: this.handleSave,
        loading: saveLoading
      }, intl.get('cpaas.common.button.save').d('保存')), /*#__PURE__*/React.createElement(Button, {
        icon: "sync",
        onClick: this.handleRefresh
      }, intl.get('cpaas.common.button.refresh').d('刷新')), !tenantRoleLevel && /*#__PURE__*/React.createElement(Lov, {
        className: "page-head-operation",
        style: {
          width: '200px'
        },
        value: currentTenantId,
        allowClear: false,
        textValue: tenantName,
        code: "CPFM.TENANT",
        onChange: function onChange(text, record) {
          _this5.handleChangeOrg(record);
        }
      })), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(EditTable, editTableProps)));
    }
  }]);

  return ReceiveConfig;
}(Component), (_applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleAddLine", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleAddLine"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSave", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSave"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCancel", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCancel"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleEdit", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "handleEdit"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCleanLine", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCleanLine"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDelete", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDelete"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "onExpand", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "onExpand"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleChangeOrg", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleChangeOrg"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRefresh", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRefresh"), _class2.prototype)), _class2)) || _class) || _class);
export { ReceiveConfig as default };